package com.hqy.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hqy.user.mapper.UserAddressMapper;
import com.hqy.user.service.UserService;
import com.hqy.user.dto.UserAddress;
import com.hqy.user.util.GmallThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserAddressMapper userAddressMapper;

    /**
     * 根据用户名获取用户地址
     *
     * @return
     */
    @Override
    public List<UserAddress> getUserAddressList() {
        String username= GmallThreadLocalUtil.get();
        List<UserAddress> userAddresses = userAddressMapper.selectList(new LambdaQueryWrapper<UserAddress>().eq(UserAddress::getUserId, username));
        return userAddresses;
    }
}
